package com.mcintyret.site.web.controller;

import com.mcintyret.site.journal.JournalFamily;
import com.mcintyret.site.journal.database.JournalFamilyDao;
import com.mcintyret.site.users.User;
import com.mcintyret.site.users.database.UsersDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * User: mcintyret2
 * Date: 15/04/2012
 */

@Service
public class AdminHelper {

    @Resource
    private UsersDao usersDao;
    @Resource
    private JournalFamilyDao journalFamilyDao;

    @Transactional("usersTransactionManager")
    public List<User> getAllUsers() {
        return usersDao.getAllUsers();
    }

    @Transactional("usersTransactionManager")
    public User getUser(String username) {
        return usersDao.retrieveUser(username);
    }


    public List<JournalFamily> getAllJournalFamiliesForUser(String username) {
        return journalFamilyDao.getAllForUser(username);
    }
}
